<template>
	<view class="content">
		<!-- 分段选择器 -->
		<uni-segmented-control class="controlBox" :current="current" :values="items" @clickItem="onClickItem"
			styleType="text" activeColor="#C00204"></uni-segmented-control>
		<view>
			<view v-show="current === 0">
				<!-- 显示中西药品 -->
				<sortItem :sortData="integratedMedicineArr"></sortItem>
			</view>
			<view v-show="current === 1">
				<!-- 显示成人用品 -->
				<sortItem :sortData="adultProductsArr"></sortItem>
			</view>
		</view>
	</view>
</template>

<script>
	import sortData from "@/static/sortData.js"
	export default {
		data() {
			return {
				items: ['中西药品', '成人用品'],
				current: 0,
				integratedMedicineArr: [],
				adultProductsArr: []
			};
		},
		methods: {
			onClickItem(e) {
				if (this.current != e.currentIndex) {
					this.current = e.currentIndex;
				}
			},
			getSortData() {
				this.integratedMedicineArr = sortData.integratedMedicine
				this.adultProductsArr = sortData.adultProducts
			}
		},
		onLoad() {
			this.getSortData()
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F6F6F6;
	}

	.content {
		display: block;
	}

	.controlBox {
		height: 100rpx;

		::v-deep .segmented-control__text {
			font-size: 30rpx;
			line-height: 100rpx;
		}
	}
</style>